// 点击创建按钮时
var btn = document.getElementById("btn");

btn.onclick = function () {
    var telValue = tel.value;
    var pwdValue = pwd.value;
    var yzmValue = yzm.value;

    var telrge = /^1[3-9[0-9]{9}$/;


    if (telValue.length == 0) {
        error1.innerHTML = "此项必须填写"
    } else if (!telrge.test(telValue)) {
        error1.innerHTML = "手机号无效";
    }

    if (pwdValue.length == 0) {
        error2.innerHTML = "此项必须填写";
        error2.className = "error";
        pwd.className = "";
    } else if (pwdValue.length < 6) {
        error2.innerHTML = "密码至少6位，支持数字、字母和符号";
        error2.className = "error";
        pwd.className = "";
    } else if (pwdValue.length < 8) {
        error2.innerHTML = "强度高的密码至少需要8个字符，同时包含大小写字母、数字和符号。";
        pwd.className = "warnbg";
        error2.className = "warn";
    } else {
        error2.innerHTML = "";
    }

    if (yzmValue.length == 0) {
        error3.innerHTML = "此项必须填写"
    }
};
//但光标进入手机号码输入框时
tel.onfocus = function () {
    error1.innerHTML = "";

};
pwd.onfocus = function () {
    error2.innerHTML = "";
};
yzm.onfocus = function () {
    error3.innerHTML = "";
};

//获取验证码
getyzmbtn.onclick = function () {
    var i = 60;
    getyzmbtn.innerHTML = i + "秒后重新获取";
    var timer = setInterval(function () {
        i--;
        if (i == 0) {
            getyzmbtn.innerHTML = "获取验证码";
            clearInterval(timer);
            return;
        }
        getyzmbtn.innerHTML = i + "秒后重新获取"
    }, 1000);
};